package com.fc.mall.portal.service;

import com.fc.mall.base.object.Result;
import com.fc.mall.model.OmsCartItem;
import com.fc.mall.model.OmsOrder;
import com.fc.mall.portal.domain.ConfirmOrderResult;
import com.fc.mall.portal.domain.OmsOrderFromFans;
import com.fc.mall.portal.domain.OrderParam;
import com.fc.mall.portal.dto.OmsOrderQueryParam;
import com.fc.mall.portal.vo.OmsOrderVO;
import com.fc.mall.portal.vo.OrderCountByStatusVO;
import com.fc.mall.portal.wechat.dto.WXPaymentResponse;
import com.github.pagehelper.PageInfo;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * 前台订单管理Service
 * Created by dobuy on 2018/8/30.
 */
public interface OmsPortalOrderService {

    /**
     * 根据订单ID获取订单信息
     * @param orderId
     * @return
     */
    OmsOrder getById(Long orderId);


    OmsOrderVO getOrderVOById(Long orderId);
    /**
     * 根据用户购物车信息生成确认单信息
     */
    ConfirmOrderResult generateConfirmOrder(String cartIds);

    /**
     * 立即下单
     * @param omsCartItems
     * @return
     */
    ConfirmOrderResult generateConfirmOrder(List<OmsCartItem> omsCartItems);

    /**
     * 根据购物车中商品，提交信息生成订单
     */
    @Transactional
    Result generateOrder(OrderParam orderParam, String cartIds);


    /**
     * 根据选中商品，提交信息生成订单
     */
    @Transactional
    Result generateOrder(OrderParam orderParam, List<OmsCartItem> omsCartItems);

    /**
     * 支付成功后的回调
     */
    @Transactional
    Result paySuccess(String orderNumber);

    /**
     * 自动取消超时订单
     */
    @Transactional
    Result cancelTimeOutOrder();

    /**
     * 取消单个超时订单
     */
    @Transactional
    void cancelOrder(Long orderId);

    /**
     * 发送延迟消息取消订单
     */
    void sendDelayMessageCancelOrder(Long orderId);

    /**
     * 查询订单列表
     */
    PageInfo<OmsOrderVO> list(OmsOrderQueryParam queryParam, Integer pageSize, Integer pageNum);

    /**
     * 统计当前用户所有订单状态数量
     * @return
     */
    OrderCountByStatusVO countOrderByStatus();

    /**
     *
     * @param orderNumber
     * @param spbillCreateIp
     * @return
     */
    WXPaymentResponse unifiedOrder(String orderNumber, String spbillCreateIp);

    String payCallback(String notifyXml);

    String refundCallback(Map<String, String> notificationMap);

    List<OmsOrderFromFans> getfansOrderList();

    int updateOrderStatus(String orderNumber, Integer status);

    String generateOrderSn(OmsOrder order);

}
